﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using System.Data.SqlClient;
using ECONTACT.Controller;

namespace ECONTACT
{
    public partial class frmNamHoc : Form
    {
        NamHocCtrl m_NamHocCtrl = new NamHocCtrl();

        public frmNamHoc()
        {
            InitializeComponent();
        }

        private void frmNamHoc_Load(object sender, EventArgs e)
        {
            m_NamHocCtrl.HienThi(dGVNamHoc,txtMaNH,txtTenNamHoc);
        }

        private void btnThem_Click(object sender, EventArgs e)
        {
            m_NamHocCtrl.LuuNamHoc(txtTenNamHoc.Text);
            m_NamHocCtrl.HienThi(dGVNamHoc, txtMaNH, txtTenNamHoc);
        }

        private void btnCapNhat_Click(object sender, EventArgs e)
        {
            m_NamHocCtrl.UpdateNamHoc(txtMaNH.Text, txtTenNamHoc.Text);
            m_NamHocCtrl.HienThi(dGVNamHoc, txtMaNH, txtTenNamHoc);
        }

        private void btnXoa_Click(object sender, EventArgs e)
        {
            if (dGVNamHoc.RowCount == 0)
            {
                MessageBox.Show("Bạn chưa chọn dòng nào làm sao xóa!", "Thông báo");
            }
            else if (MessageBoxEx.Show("Bạn có chắc là xóa thiệt hok ?", "DELETE", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                m_NamHocCtrl.DeleteNamHoc(txtMaNH.Text);
                m_NamHocCtrl.HienThi(dGVNamHoc, txtMaNH, txtTenNamHoc);
            }
        }
    }
}
